# -*- coding:utf-8 -*-
'''
Created on 02.03.2010

@author: yserdyukov
'''
import settings
from django.contrib.admin.widgets import AdminTimeWidget, AdminSplitDateTime
from django import forms
from django.utils.safestring import mark_safe


class CUDateWidget(forms.DateInput):
    class Media:
        js = (settings.ADMIN_MEDIA_PREFIX + "js/admin/DateTimeShortcuts.js",
              settings.STATIC_DOC_URL + "js/ui.core.js",
              settings.STATIC_DOC_URL + "js/ui.datepicker.js",
              settings.STATIC_DOC_URL + "js/ui.datepicker-ru.js",
              settings.STATIC_DOC_URL + "js/datepicker.init.js",
             )
        css = { 'all': (settings.STATIC_DOC_URL + 'css/jquery-ui.css',)  }

    def __init__(self, attrs={}):
        if attrs == None:
            attrs = {}
        attrs['class'] = 'vCUDateField'
        attrs['size'] = '10'
        super(CUDateWidget, self).__init__(attrs, format='%d.%m.%Y')

class CUDateTimeWidget(AdminSplitDateTime):
#    class Media:
#        js = (settings.MEDIA_URL + "js/DateTimeShortcutsTender.js",)
    def __init__(self, attrs=None):
        widgets = [CUDateTimeWidget(attrs=attrs), AdminTimeWidget]
        # Note that we're calling MultiWidget, not SplitDateTimeWidget, because
        # we want to define widgets.
        forms.MultiWidget.__init__(self, widgets, attrs)
